﻿
//北边面板，标题栏
var north_item = new Ext.Panel({
    id: "nortPanel",
    region: 'north',
    contentEl: 'north-div',
    border: false

});

//南边面板，状态栏   
var south_item = new Ext.Panel({
    region: 'south',
    contentEl: 'south-div'

});

//东边，快捷栏（暂无使用）
var east_item = new Ext.Panel({
    id: 'eastpanel',
    region: 'east',
    el: 'center-center',
    title: '快捷栏',
    split: true,
    collapsible: true,
    titlebar: true,
    collapsedTitle: '内容',
    height: 200,
    width: 200,
    minSize: 100,
    maxSize: 400
});


//中间的南边,信息内容
var center_south_item = new Ext.TabPanel({
    region: 'center',
    contentEl: 'center-south',
    enableTabScroll: true,
    autoScroll: true,
    closable: true,
    activeTab: 0,
    plugins: new Ext.ux.TabCloseMenu()    ,
items: [{
        id: 'zhuye',
        html: '<iframe id="main" src="Homepage.aspx" width="100%" height=100% name="main"  frameborder="0" scrolling="auto" style="border:0px none; background-color:#BBBBBB; "  ></iframe>',
        title: '<img src="/App_Themes/Images/Default/house.gif" width="14" height="14" alt="" style="vertical-align:middle"/>&nbsp;主页'
        //autoScroll: true,
       // autoLoad: { url: '/Web/Scheduling/Sch_FlowTrackingList.aspx', scripts: true }
}],
        initEvents: function() {
            Ext.TabPanel.superclass.initEvents.call(this);
            this.on('add', this.onAdd, this, { target: this });
            this.on('remove', this.onRemove, this, { target: this });
            this.mon(this.strip, 'mousedown', this.onStripMouseDown, this);
            this.mon(this.strip, 'contextmenu', this.onStripContextMenu, this);
            if (this.enableTabScroll) {
                this.mon(this.strip, 'mousewheel', this.onWheel, this);
            }
            this.mon(this.strip, 'dblclick', this.onTitleDbClick, this);
        },
        onTitleDbClick: function(e, target, o) {
            var t = this.findTargets(e);
            if (t.item.fireEvent('beforeclose', t.item) !== false && t.item.id != 'zhuye') {
                t.item.fireEvent('close', t.item);
                this.remove(t.item);
            }
        }
    });

    //中间面板   
    var center_item = new Ext.Panel({
        region: 'center',
        layout: 'border',
        items: [center_south_item]  //,east_item
    });

    var tabconut = 12; //标签累计总页数
    var messinfo = "只能打开12个标签页，请删除后打开！(温馨提示：双击鼠标左键可快速删除标签页)"; //信息提醒
    //点击菜单，右边添加选项卡显示
    function TreeClick(node, event) {
        event.stopEvent();
        var vhref = node.attributes.href;
        center_south_item
        if (vhref != null && vhref != "") {
            var n = center_south_item.getComponent(node.id);
            if (!n) {
                if (tabconut > 0) {
                    n = center_south_item.add({ id: node.id, closable: true,
                        html: '<iframe src="" name="ifr" id="ifr"  width="100%" height="100%"  frameborder="0" scrolling="auto" style="border:0px none; background-color:#BBBBBB; "  ></iframe>',
                        listeners: { 'beforedestroy': function(e) { tabconut++; } }
                    }).show();
                    tabconut--;
                    n.setTitle("<img src='" + node.attributes.icon + "' style='vertical-align:middle'alt=''/>&nbsp;" + node.text);
                    var ipos = vhref.indexOf(".");
                    if (ipos != -1) {
                        ifr.location.href = vhref;
                    } else {
                        ifr.location.href = vhref + ".aspx";
                    }

                    center_south_item.setActiveTab(n);
                }
                else {
                    alert(messinfo);
                }
            }
            else center_south_item.setActiveTab(n);
        }
    }
    //添加链接，右边添加选项卡显示
    this.addUrl = function(id, url, titles, iconurl) {
        var vhref = url;
        if (vhref != null && vhref != "") {
            var n = center_south_item.getComponent(id);
            if (!n) {
                if (tabconut > 0) {
                    n = center_south_item.add({ id: id, closable: true,
                        html: '<iframe src="" name="ifr" id="ifr"  width="100%" height="100%"  frameborder="0" scrolling="auto" style="border:0px none; background-color:#BBBBBB; "  ></iframe>',
                        listeners: { 'beforedestroy': function(e) { tabconut++; } }
                    }).show();
                    tabconut--;
                    if (iconurl == "") n.setTitle(titles);
                    else n.setTitle("<img src='" + iconurl + "' alt='' width='16' height='16' style='vertical-align:middle'/>&nbsp;" + titles);
                    ifr.location.href = vhref;
                    center_south_item.setActiveTab(n);
                }
                else {
                    alert(messinfo);
                }
            }
            else center_south_item.setActiveTab(n);
        }
    }        